home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2006 May
/
PCWMAY06.iso
/
Software
/
Freeware
/
First Page 2006 3.00
/
fp2006-final-3.00-setup.exe
/
{app}
/
Iscripts
/
Image & Music Effects
/
graphs-it.izs
< prev
next >
Wrap
Text File
|
2005-07-30
|
4KB
|
169 lines
<!NOWIZARD>
<!TITLE>JavaScript Graph-it!
<!/TITLE>
<!DESCRIPTION>Create graphs out of raw data using Graph It! Just input the name/value pairs of the involved graph elements, and leave the rest to the script. The values can be either absolute or percentage (using two versions of script).
<!/DESCRIPTION>
<!CATEGORY>img and music effects<!/CATEGORY>
<!SCRIPT>
<!-- START OF SCRIPT -->
What is your favorite news site?
<script language="JavaScript1.2">
var graphimage="poll.gif"
//DEFINE GRAPH VALUES [Item name, absolute value]
var graphx=new Array()
graphx[0]=["CNN",60]
graphx[1]=["MSNBC",75]
graphx[2]=["ABC News",24]
graphx[3]=["BBC News",52]
//YOU CAN DEFINE MULTIPLE GRAPHS, eg:
//var graphy=new Array()
function graphit(g,gwidth){
total=0
for (i=0;i<g.length;i++)
total+=parseInt(g[i][1])
output='<table border="0" cellspacing="0" cellpadding="0">'
for (i=0;i<g.length;i++){
calpercentage=Math.round(g[i][1]*100/total)
calwidth=Math.round(gwidth*(calpercentage/100))
output+='<tr><td>'+g[i][0]+' </td><td><img src="'+graphimage+'" width="'+calwidth+'" height="10"> '+calpercentage+'%</td></tr>'
}
output+='</table>'
document.write(output+'<br>Total participants: <b>'+total+'</b>')
}
//CALL GRAPHIT FUNCTION
//graphit(NAME OF GRAPH ARRAY, MAXIMUM WIDTH IN PIXELS)
graphit(graphx,200)
</script>
What is your favorite news site?
<script language="JavaScript1.2">
//JavaScript Graph-it! (Percentage)- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use
var graphimageP="poll.gif"
//DEFINE GRAPH VALUES [Item name, Percentage value]
var graphv=new Array()
graphv[0]=["CNN","28%"]
graphv[1]=["MSNBC","36%"]
graphv[2]=["ABC News","11%"]
graphv[3]=["BBC News","25%"]
//YOU CAN DEFINE MULTIPLE GRAPHS, eg:
//var graphz=new Array()
function graphitP(g,gwidth){
outputP='<table border="0" cellspacing="0" cellpadding="0">'
for (i=0;i<g.length;i++){
calwidthP=gwidth*(parseInt(g[i][1])/100)
outputP+='<tr><td>'+g[i][0]+' </td><td><img src="'+graphimageP+'" width="'+calwidthP+'" height="10"> '+g[i][1]+'</td></tr>'
}
outputP+='</table>'
document.write(outputP)
}
//CALL GRAPHIT FUNCTION
//graphitP(NAME OF GRAPH ARRAY, MAXIMUM WIDTH IN PIXELS)
graphitP(graphv,200)
</script>
<!-- END OF SCRIPT -->
<!/SCRIPT>
<!PREVIEW>
<!-- START OF SCRIPT -->
<!-- START OF SCRIPT -->
What is your favorite news site?
<script language="JavaScript1.2">
var graphimage="poll.gif"
//DEFINE GRAPH VALUES [Item name, absolute value]
var graphx=new Array()
graphx[0]=["CNN",60]
graphx[1]=["MSNBC",75]
graphx[2]=["ABC News",24]
graphx[3]=["BBC News",52]
//YOU CAN DEFINE MULTIPLE GRAPHS, eg:
//var graphy=new Array()
function graphit(g,gwidth){
total=0
for (i=0;i<g.length;i++)
total+=parseInt(g[i][1])
output='<table border="0" cellspacing="0" cellpadding="0">'
for (i=0;i<g.length;i++){
calpercentage=Math.round(g[i][1]*100/total)
calwidth=Math.round(gwidth*(calpercentage/100))
output+='<tr><td>'+g[i][0]+' </td><td><img src="'+graphimage+'" width="'+calwidth+'" height="10"> '+calpercentage+'%</td></tr>'
}
output+='</table>'
document.write(output+'<br>Total participants: <b>'+total+'</b>')
}
//CALL GRAPHIT FUNCTION
//graphit(NAME OF GRAPH ARRAY, MAXIMUM WIDTH IN PIXELS)
graphit(graphx,200)
</script>
What is your favorite news site?
<script language="JavaScript1.2">
//JavaScript Graph-it! (Percentage)- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use
var graphimageP="poll.gif"
//DEFINE GRAPH VALUES [Item name, Percentage value]
var graphv=new Array()
graphv[0]=["CNN","28%"]
graphv[1]=["MSNBC","36%"]
graphv[2]=["ABC News","11%"]
graphv[3]=["BBC News","25%"]
//YOU CAN DEFINE MULTIPLE GRAPHS, eg:
//var graphz=new Array()
function graphitP(g,gwidth){
outputP='<table border="0" cellspacing="0" cellpadding="0">'
for (i=0;i<g.length;i++){
calwidthP=gwidth*(parseInt(g[i][1])/100)
outputP+='<tr><td>'+g[i][0]+' </td><td><img src="'+graphimageP+'" width="'+calwidthP+'" height="10"> '+g[i][1]+'</td></tr>'
}
outputP+='</table>'
document.write(outputP)
}
//CALL GRAPHIT FUNCTION
//graphitP(NAME OF GRAPH ARRAY, MAXIMUM WIDTH IN PIXELS)
graphitP(graphv,200)
</script>
<!-- END OF SCRIPT -->
<!/PREVIEW>
<!RELATED>NONE<!/RELATED>